<script>
    
$(document).ready(function() {    
    $( ".useritem, .addEmoloyeeBack" ).click(function() { 
         var url = $(this).attr('url');         
         $('#txtEmployeeId').val($(this).attr('rel'));    
         $('#frmCompanyCode').attr('action', url);  
         $( "#frmCompanyCode" ).submit();   
       
    });
 }); 
</script>
<form id="frmCompanyCode" action="" method="POST">
  <input type="hidden" id="txtEmployeeId" name="txtEmployeeId">      
</form>

<div id="main_content" class="updateSalaryInfo">
    <h3><?php echo $title; ?></h3>
    <a rel="<?php echo $id ?>" url="<?php echo base_url('/employee/leave-info' ); ?>" href="javascript:void(0);"  class="btn addEmoloyeeBack m10"><?php echo $btnBack; ?></a>    
    <div class="form_add">   
        <form action="" method="post">
            <table border="0" class="add_data">
                <tr>
                    <td align="right"><label><?php echo $lblEmployeeName; ?></label></td>
                    <td><label><a rel="<?php echo $id ?>" url="<?php echo base_url('/employee/update' ); ?>" href="javascript:void(0);" class="useritem"><?php echo dQuotes(subString($employeeName,15)); ?></a></label></td>
                    <td></td>
                </tr>
                <tr>
                    <td align="right"><label><?php echo $lblAvailableLeave; ?> <font color="#FF0000">(*)</font></label></td>
                     <input type="hidden" id="txtApplyDateOld" name="txtApplyDateOld" value="<?php if(isset($cboYear)){echo $cboYear;} ?>">
                    <td><input type="hidden" name="txtEmployeeId" class="txtEmployeeId" value="<?php echo $id; ?>">
                        <input type="hidden" name="txtEmployeeleaveinfoId" class="txtEmployeeleaveinfoId" value="<?php echo isset($EmployeeleaveinfoId) ? $EmployeeleaveinfoId : ''; ?>">
                        <input type="text" name="txtAvailableLeave" size="20" value="<?php echo $txtAvailableLeave; ?>" maxlength="2"/>
                    </td>
                    <td><div class="error"><?php echo form_error('txtAvailableLeave'); ?></div></td>
                </tr>
                <tr>
                    <td align="right"><label><?php echo $lblYear; ?></label></td>
                    <td>
                        <select name="cboYear">
                            <?php 
                                $year = $this->config->item('rangeYear');
                                if(isset($cboYear) && $cboYear!=''){
                                    for($i=$year['minYear'];$i<=$year['maxYear'];$i++){
                                        ?>
                                            <option value="<?php echo $i; ?>" <?php if($i==$cboYear){echo "selected = 'selected' ";} ?> ><?php echo $i; ?></option>
                                        <?php
                                    }                                    
                                }
                                else{
                                    for($i=$year['minYear'];$i<=$year['maxYear'];$i++){
                                        ?>
                                            <option value="<?php echo $i; ?>" <?php if($i==date("Y")){echo "selected = 'selected' ";} ?> ><?php echo $i; ?></option>
                                        <?php
                                    }                                     
                                }
                            ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right"><label><?php echo $lblSpecialDate; ?> </label></td>
                    <td>
                        <input type="text" name="txtSpecialDate" size="20" maxlength="10" class="datepicker" value="<?php if($txtSpecialDate){echo $txtSpecialDate;}else{echo '';} ?>" />
                        (<?php echo $this->lang->line('formatDay'); ?>)
                    </td>
                    <td><div class="error"><?php echo form_error('txtSpecialDate'); ?></div></td>
                </tr> 
                <?php  if(isset($EmployeeleaveinfoId) && !empty($EmployeeleaveinfoId)){ ?>
                <tr>
                    <td align="right"><?php echo $this->lang->line('spl__Delete');?></td>
                    <td><input type="checkbox" <?php echo ($chkDelete==1) ? 'checked' : ''?> name="chkDelete" /></td>
                </tr>
                <?php } ?>
                <tr>
                    <td align="left"><input type="submit" name="btnSubmit" value="<?php echo $btnSubmit; ?>"></td>            
                    <td></td>
                    <td></td>
                </tr>                                                                                         
            </table> 
        </form>
    </div>
</div>
<!-- BEGIN dialog message -->
<div id="dialog" title="<?php echo $dialogTitle; ?>">
    <?php echo isset($message) ? $message : ''; ?>
</div>
<!-- END dialog message -->
<script type="text/javascript">
    $(document).ready(function() {
        $(function() {
            $(".datepicker").datepicker({
                dateFormat: 'yy/mm/dd',
                showOn: "button",
                buttonImage: "<?php echo base_url(); ?>/public/sites/images/calendaricon.gif",
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                yearRange: '<?php echo $minYear . ':' . $maxYear; ?>'
            });
        });        
<?php if (isset($flag) && $flag == TRUE): ?>
            $(function() {
                $("#dialog").dialog({
                    modal: true,
                    close: function() {
                        $('#txtEmployeeId').val('<?php echo $id ?>');       
                            $('#frmCompanyCode').attr('action', '<?php echo base_url();?>employee/leave-info');  
                            $( "#frmCompanyCode" ).submit();                        
                    },
                    buttons: [{
                        text: "<?php echo $this->lang->line('MC019');?>",
                        click: function() {
                            $('#txtEmployeeId').val('<?php echo $id ?>');       
                            $('#frmCompanyCode').attr('action', '<?php echo base_url();?>employee/leave-info');  
                            $( "#frmCompanyCode" ).submit(); 
                        },
                    }]
                });
            });
<?php elseif (isset($flag) && $flag == FALSE): ?>
            $(function() {
                $("#dialog").dialog({
                buttons: [
                    { text: "Close", click: function() { $( this ).dialog( "close" ); } }
                ]
                });
            });
<?php endif; ?>
    });
</script>